#!/usr/bin/python3
# -*- coding: utf-8; tab-width: 4; indent-tabs-mode: t -*-

import os
import strict_portage


class FmConst:

    programName = "fpemud-os-sysman"

    libDir = os.path.join("/usr/lib64", programName)
    libexecDir = os.path.join("/usr/libexec", programName)
    dataDir = os.path.join("/usr/share", programName)

    portageProfile = "profiles/default/linux/amd64/23.0"

    portageDataDir = "/var/lib/portage"
    portageCacheDir = "/var/cache/portage"
    portageDbDir = "/var/db/pkg"

    portageMirrorsFile = os.path.join(strict_portage.cfg.PortageConfigDir().path, "mirrors")
    portageCfgMakeProfile = os.path.join(strict_portage.cfg.PortageConfigDir().path, "make.profile")
    portageCfgMakeConf = os.path.join(strict_portage.cfg.PortageConfigDir().path, "make.conf")
    portageCfgReposDir = os.path.join(strict_portage.cfg.PortageConfigDir().path, "repos.conf")
    portageCfgUseDir = os.path.join(strict_portage.cfg.PortageConfigDir().path, "package.use")
    portageCfgRepoPostsyncDir = os.path.join(strict_portage.cfg.PortageConfigDir().path, "repo.postsync.d")
    portageCfgSetsDir = os.path.join(strict_portage.cfg.PortageConfigDir().path, "sets")

    bbkiKernelFile = os.path.join(strict_portage.cfg.PortageConfigDir().path, "bbki.kernel")
    bbkiKernelAddonDir = os.path.join(strict_portage.cfg.PortageConfigDir().path, "bbki.kernel_addon")

    configArchiveDir = os.path.join(portageDataDir, "config-archive")

    cloudOverlayDbDir = os.path.join(portageCacheDir, "overlay-db")
    laymanfilesDir = os.path.join(portageCacheDir, "laymanfiles")
    distDir = os.path.join(portageCacheDir, "distfiles")
    gentooLinuxCacheDir = os.path.join(portageCacheDir, "gentoo-linux")
    mswinCacheDir = os.path.join(portageCacheDir, "mswin")

    stage4CacheDir = os.path.join(portageCacheDir, "stage4")
    stage4AssistOsAmd64CacheDir = os.path.join(stage4CacheDir, "assist_os-amd64")
    stage4AssistOsArm64CacheDir = os.path.join(stage4CacheDir, "assist_os-arm64")
    stage4GentooAmd64CacheDir = os.path.join(stage4CacheDir, "stage4-gentoo-amd64")
    stage4GentooArm64CacheDir = os.path.join(stage4CacheDir, "stage4-gentoo-arm64")
    stage4WinXpCacheDir = os.path.join(stage4CacheDir, "stage4-mswin_xp")
    stage4Win7CacheDir = os.path.join(stage4CacheDir, "stage4-mswin_7")

    ccacheDir = "/var/cache/ccache"

    cfgDispatchConf = "/etc/dispatch-conf.conf"

    userUsrmanCfgDir = ".config/usrman"     # FIXME: decouple with usrman?
    userUsrmanCacheDir = ".cache/usrman"    # FIXME: decouple with usrman?
    userDefaultPassword = "123456"

    assistDiskName = "Fpemud OS Assistant Disk"
    assistDiskLabel = "ASSIST"

    supportElementTypes = ["cd-album", "game", "movie", "tv-show", "wallpaper"]

    buildServerDefaultPort = 2108
    buildServerConfFile = os.path.join(strict_portage.cfg.PortageConfigDir().path, "build-server.conf")
    myCertFile = os.path.join(strict_portage.cfg.PortageConfigDir().path, "cert.pem")
    myPrivKeyFile = os.path.join(strict_portage.cfg.PortageConfigDir().path, "privkey.pem")
    myKeySize = 2048

    rcWifiSsid = "FPEMUD_OS_ASSIST_DISK"


class FmParam:

    def __init__(self):
        super().__init__()

        self.singletonFile = "/run/sysman"
        self.tmpDir = "/tmp/sysman"

        self.runMode = None             # "normal" | "prepare" | "setup"

        # business objects
        self.infoPrinter = None
        self.logManager = None
        self.otherHostManager = None
        self.userManager = None
        self.sysChecker = None
        self.sysUpdater = None
        self.sysCleaner = None


class FmError(Exception):
    pass
